package com.ssm.controller;

import com.ssm.service.UserRedPacketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/userRedPacket" )
public class UserRedPacketController {
    @Autowired
    private UserRedPacketService userRedPacketService = null;
    @RequestMapping("/grapRedPacket" )
    @ResponseBody
    public Map<String, Object> grapRedPacket (Long redPacketid, Long userid){
        //抢红包
        //System.out.println("抢红包");
        int result=userRedPacketService .grapRedPacket(redPacketid, userid);
        Map<String, Object> retMap =new HashMap<String, Object>();
        boolean flag = result > 0;
        retMap.put ("success", flag);
        retMap .put ("message", flag?"抢红包成功":"抢红包失败" );
        return retMap;
    }
}
